package bookmanage;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JDesktopPane;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;

public class BMMain extends JFrame {

	JDesktopPane contentPane;
	private JMenuBar menuBar;
	private JMenu mnNewMenu;
	private JMenuItem mntmNewMenuItem;
	private JMenuItem mntmNewMenuItem_1;
	private JMenuItem mntmNewMenuItem_2;
	private JMenu mnNewMenu_1;
	private JMenuItem mntmNewMenuItem_3;
	private JMenuItem mntmNewMenuItem_4;
	private JMenu mnNewMenu_2;
	private JMenu mnNewMenu_3;
	private JMenuItem mntmNewMenuItem_5;
	private JMenuItem mntmNewMenuItem_8;
	private JMenuItem mntmNewMenuItem_7;
	private JMenuItem mntmNewMenuItem_9;
	private JMenuItem mntmNewMenuItem_10;
	private JMenuItem mntmNewMenuItem_11;
	private JMenuItem mntmNewMenuItem_13;
	private JMenuItem mntmNewMenuItem_14;
	private JMenuItem mntmNewMenuItem_16;
	private JMenuItem mntmNewMenuItem_17;
	private JMenuItem mntmNewMenuItem_19;
	private JMenuItem mntmNewMenuItem_20;
	private JMenuItem mntmNewMenuItem_22;
	private JMenuItem mntmNewMenuItem_21;
	private JMenuItem mntmNewMenuItem_23;
	private JMenuItem mntmNewMenuItem_6;
	private JMenuItem mntmNewMenuItem_18;

	Connection con;
	MemberEditDel med;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BMMain frame = new BMMain();
					UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
					SwingUtilities.updateComponentTreeUI(frame);
			        UIManager.put("InternalFrame.titleFont", new Font("Gulim", Font.PLAIN, 11));
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BMMain() {
		setTitle("도서 관리 프로그램");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 900, 700);
		setJMenuBar(getMenuBar_1());
		contentPane = new JDesktopPane();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		ConnectDB db = new ConnectDB();
		db.connect();
		db.createTable();
		con = db.con;
	}

	private JMenuBar getMenuBar_1() {
		if (menuBar == null) {
			menuBar = new JMenuBar();
			menuBar.add(getMnNewMenu());
			menuBar.add(getMnNewMenu_1());
			menuBar.add(getMnNewMenu_2());
			menuBar.add(getMnNewMenu_3());
		}
		return menuBar;
	}
	private JMenu getMnNewMenu() {
		if (mnNewMenu == null) {
			mnNewMenu = new JMenu("메뉴");
			mnNewMenu.add(getMntmNewMenuItem());
			mnNewMenu.add(getMntmNewMenuItem_1());
			mnNewMenu.add(getMntmNewMenuItem_2());
		}
		return mnNewMenu;
	}
	private JMenuItem getMntmNewMenuItem() {
		if (mntmNewMenuItem == null) {
			mntmNewMenuItem = new JMenuItem("로그인");
			mntmNewMenuItem.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
				}
			});
		}
		return mntmNewMenuItem;
	}
	private JMenuItem getMntmNewMenuItem_1() {
		if (mntmNewMenuItem_1 == null) {
			mntmNewMenuItem_1 = new JMenuItem("로그아웃");
			mntmNewMenuItem_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
				}
			});
		}
		return mntmNewMenuItem_1;
	}
	private JMenuItem getMntmNewMenuItem_2() {
		if (mntmNewMenuItem_2 == null) {
			mntmNewMenuItem_2 = new JMenuItem("종료");
			mntmNewMenuItem_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
				}
			});
		}
		return mntmNewMenuItem_2;
	}
	private JMenu getMnNewMenu_1() {
		if (mnNewMenu_1 == null) {
			mnNewMenu_1 = new JMenu("회원관리");
			mnNewMenu_1.add(getMntmNewMenuItem_3());
			mnNewMenu_1.add(getMntmNewMenuItem_4());
			mnNewMenu_1.add(getMntmNewMenuItem_5());
			mnNewMenu_1.add(getMntmNewMenuItem_6());
			mnNewMenu_1.add(getMntmNewMenuItem_7());
			mnNewMenu_1.add(getMntmNewMenuItem_8());
			mnNewMenu_1.add(getMntmNewMenuItem_9());
		}
		return mnNewMenu_1;
	}
	private JMenuItem getMntmNewMenuItem_3() {
		if (mntmNewMenuItem_3 == null) {
			mntmNewMenuItem_3 = new JMenuItem("회원 등록");
			mntmNewMenuItem_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					MemberInsert mi = new MemberInsert(BMMain.this);
					contentPane.add(mi);
					mi.setBounds(50, 50, 500, 540);
					mi.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_3;
	}
	private JMenuItem getMntmNewMenuItem_4() {
		if (mntmNewMenuItem_4 == null) {
			mntmNewMenuItem_4 = new JMenuItem("회원 정보 조회");
			mntmNewMenuItem_4.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					MemberSelect ms = new MemberSelect(BMMain.this);
					contentPane.add(ms);
					ms.setBounds(50, 50, 650, 300);
					ms.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_4;
	}
	private JMenuItem getMntmNewMenuItem_5() {
		if (mntmNewMenuItem_5 == null) {
			mntmNewMenuItem_5 = new JMenuItem("회원 수정/삭제");
			mntmNewMenuItem_5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					med = new MemberEditDel(BMMain.this);
					contentPane.add(med);
					med.setBounds(50, 50, 500, 550);
					med.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_5;
	}
	private JMenuItem getMntmNewMenuItem_7() {
		if (mntmNewMenuItem_7 == null) {
			mntmNewMenuItem_7 = new JMenuItem("연체료 납입 현황");
			mntmNewMenuItem_7.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
				}
			});
		}
		return mntmNewMenuItem_7;
	}
	private JMenuItem getMntmNewMenuItem_9() {
		if (mntmNewMenuItem_9 == null) {
			mntmNewMenuItem_9 = new JMenuItem("독서왕 조회");
			mntmNewMenuItem_9.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
				}
			});
		}
		return mntmNewMenuItem_9;
	}
	private JMenu getMnNewMenu_2() {
		if (mnNewMenu_2 == null) {
			mnNewMenu_2 = new JMenu("코드/도서관리");
			mnNewMenu_2.add(getMntmNewMenuItem_10());
			mnNewMenu_2.add(getMntmNewMenuItem_11());
			mnNewMenu_2.add(getMntmNewMenuItem_13());
			mnNewMenu_2.add(getMntmNewMenuItem_14());
		}
		return mnNewMenu_2;
	}
	private JMenuItem getMntmNewMenuItem_10() {
		if (mntmNewMenuItem_10 == null) {
			mntmNewMenuItem_10 = new JMenuItem("코드 등록");
			mntmNewMenuItem_10.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					CodeInsert ci = new CodeInsert(con);
					contentPane.add(ci);
					ci.setBounds(50, 50, 355, 170);
					ci.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_10;
	}
	private JMenuItem getMntmNewMenuItem_11() {
		if (mntmNewMenuItem_11 == null) {
			mntmNewMenuItem_11 = new JMenuItem("코드 조회");
			mntmNewMenuItem_11.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					CodeSED csed = new CodeSED(con);
					contentPane.add(csed);
					csed.setBounds(50, 50, 550, 300);
					csed.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_11;
	}
	private JMenuItem getMntmNewMenuItem_13() {
		if (mntmNewMenuItem_13 == null) {
			mntmNewMenuItem_13 = new JMenuItem("도서 등록");
			mntmNewMenuItem_13.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					BookInsert bi = new BookInsert(con);
					contentPane.add(bi);
					bi.setBounds(50, 50, 290, 280);
					bi.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_13;
	}
	private JMenuItem getMntmNewMenuItem_14() {
		if (mntmNewMenuItem_14 == null) {
			mntmNewMenuItem_14 = new JMenuItem("도서 조회");
			mntmNewMenuItem_14.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					BookSED bsed = new BookSED(con);
					contentPane.add(bsed);
					bsed.setBounds(50, 50, 700, 350);
					bsed.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_14;
	}
	private JMenu getMnNewMenu_3() {
		if (mnNewMenu_3 == null) {
			mnNewMenu_3 = new JMenu("대여관리");
			mnNewMenu_3.add(getMntmNewMenuItem_16());
			mnNewMenu_3.add(getMntmNewMenuItem_17());
			mnNewMenu_3.add(getMntmNewMenuItem_18());
			mnNewMenu_3.add(getMntmNewMenuItem_19());
			mnNewMenu_3.add(getMntmNewMenuItem_20());
			mnNewMenu_3.add(getMntmNewMenuItem_21());
			mnNewMenu_3.add(getMntmNewMenuItem_22());
			mnNewMenu_3.add(getMntmNewMenuItem_23());
		}
		return mnNewMenu_3;
	}
	private JMenuItem getMntmNewMenuItem_16() {
		if (mntmNewMenuItem_16 == null) {
			mntmNewMenuItem_16 = new JMenuItem("대출");
			mntmNewMenuItem_16.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					BookRental br = new BookRental(con);
					contentPane.add(br);
					br.setBounds(50, 50, 570, 330);
					br.setVisible(true);
				}
			});
		}
		return mntmNewMenuItem_16;
	}
	private JMenuItem getMntmNewMenuItem_17() {
		if (mntmNewMenuItem_17 == null) {
			mntmNewMenuItem_17 = new JMenuItem("반납");
		}
		return mntmNewMenuItem_17;
	}
	private JMenuItem getMntmNewMenuItem_19() {
		if (mntmNewMenuItem_19 == null) {
			mntmNewMenuItem_19 = new JMenuItem("대여 현황");
		}
		return mntmNewMenuItem_19;
	}
	private JMenuItem getMntmNewMenuItem_8() {
		if (mntmNewMenuItem_8 == null) {
			mntmNewMenuItem_8 = new JMenuItem("대출 불가자 조회");
		}
		return mntmNewMenuItem_8;
	}
	private JMenuItem getMntmNewMenuItem_20() {
		if (mntmNewMenuItem_20 == null) {
			mntmNewMenuItem_20 = new JMenuItem("예약");
		}
		return mntmNewMenuItem_20;
	}
	private JMenuItem getMntmNewMenuItem_22() {
		if (mntmNewMenuItem_22 == null) {
			mntmNewMenuItem_22 = new JMenuItem("도서 인기 순위");
		}
		return mntmNewMenuItem_22;
	}
	private JMenuItem getMntmNewMenuItem_21() {
		if (mntmNewMenuItem_21 == null) {
			mntmNewMenuItem_21 = new JMenuItem("예약 현황");
		}
		return mntmNewMenuItem_21;
	}
	private JMenuItem getMntmNewMenuItem_23() {
		if (mntmNewMenuItem_23 == null) {
			mntmNewMenuItem_23 = new JMenuItem("연체자 조회");
		}
		return mntmNewMenuItem_23;
	}
	private JMenuItem getMntmNewMenuItem_6() {
		if (mntmNewMenuItem_6 == null) {
			mntmNewMenuItem_6 = new JMenuItem("연체료 납부");
		}
		return mntmNewMenuItem_6;
	}
	private JMenuItem getMntmNewMenuItem_18() {
		if (mntmNewMenuItem_18 == null) {
			mntmNewMenuItem_18 = new JMenuItem("연기");
		}
		return mntmNewMenuItem_18;
	}
}
